<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + request.getContextPath();
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css" href="<%=basePath %>/css/updateVideo.css"/>
    <link rel="stylesheet" href="<%=basePath %>/css/list.css">
    <link href="<%=basePath %>/css/H-ui.min.css" rel="stylesheet" type="text/css"/>
    <link href="<%=basePath %>/css/formsCSS.css" rel="stylesheet" type="text/css"/>
    <script src="<%=basePath%>/lib/My97DatePicker/WdatePicker.js"></script>
    <script src="<%=basePath %>/js/jquery.min.js"></script>
    <script src="<%=basePath %>/js/formsJS.js"></script>

    <script type="text/javascript">

        function checkForm(f) {

            if (f.chapterId.value.replace(/\s/g, '') == '') {
                alert("评论章节不能为空");
                return false;
            }
            if (f.userId.value.replace(/\s/g, '') == '') {
                alert("评论人不能为空");
                return false;
            }
            if (f.commentType.value.replace(/\s/g, '') == '') {
                alert("评论类型不能为空");
                return false;
            }


            return true;
        }

    </script>
</head>
<body>
<div class="connect_wrap">
    <h3 style="text-align: center;">课程评论回复</h3>
    <div class="row cl" style="max-width:88%;margin-left:8%;">
        <div class="labelText"></div>
        <form action="<%=basePath%>/courseComment/courseCommentEdit" method="post" onsubmit="return checkForm(this)"
              enctype="multipart/form-data">
            <div class="col-sm-4"></div>
            <div class="col-sm-4">
                <div class="boxs">
                    <input type="hidden" name="id" value="${courseComment.id}">
                    <input type="text" class="inputBox" placeholder="所属课程章节" name="chapterName"
                           value="${courseComment.chapterName}" readonly="readonly">

                    <%-- <select class="selectBox" name="chapterId" id="chapterId">
                        <option value="">----所属课程章节----</option>
                        <c:forEach items="${chapters}" var="c">
                            <option value="${c.id}" ${c.id == courseComment.chapterId ? 'selected="selected"' : ''}>${c.id}:${c.chapterName}</option>
                        </c:forEach>
                    </select> --%>
                    <select id="commentType" name="commentType" class="selectBox" disabled="disabled">
                        <option value="">评论类型</option>
                        <option value="1" ${courseComment.commentType == 1 ? 'selected="selected"' : '' }>点赞</option>
                        <option value="2" ${courseComment.commentType == 2 ? 'selected="selected"' : '' }>评论</option>
                    </select>
                    <%-- <select class="selectBox" name="userId" id="userId">
                        <option value="">----评论人----</option>
                        <c:forEach items="${members}" var="m">
                            <option value="${m.userId}" ${m.userId == courseComment.userId ? 'selected="selected"' : ''}>${m.userId}:${m.userName}</option>
                        </c:forEach>
                    </select> --%>
                    <input type="text" class="inputBox" placeholder="论人" name="userName"
                           value="${courseComment.userName}" readonly="readonly">

                    <input type="text" class="inputBox" placeholder="备注" name="remark" value="${courseComment.remark}"
                           readonly="readonly">
                    <input type="text" class="inputBox" placeholder="评论内容" name="commentContent"
                           value="${courseComment.commentContent}" readonly="readonly">
                    <span>评论图片</span>
                    <img src="${WF_CONSOLE_CONFIG_OSS_URL}${courseComment.commentImage}" width="320"
                         height="320"
                         <c:if test="${empty courseComment.commentImage}">style="display: none;"</c:if> />
                    <input type="text" class="inputBox" placeholder="回复内容" name="reply" value="${courseComment.reply}">
                    <input type="file" class="inputBox" placeholder="回复图片" name="replyFile"
                           value="${courseComment.replyImage}" onchange="replyImageFunc()" id="replyImage"/>
                    <br/><br/><img src="${WF_CONSOLE_CONFIG_OSS_URL}${courseComment.replyImage}" id="replyImageShow"
                                   width="320"
                                   height="320"
                                   <c:if test="${empty courseComment.replyImage}">style="display: none;"</c:if> />
                    <select id="rec_flag" name="rec_flag" class="selectBox">
                        <option value="">是否推荐</option>
                        <option value="1" ${courseComment.rec_flag == 1 ? 'selected="selected"' : '' }>是</option>
                        <option value="2" ${courseComment.rec_flag == 2 ? 'selected="selected"' : '' }>否</option>
                    </select>
                    <br/><br/>
                    <input type="submit" value="确定" class="true"/>
                    <input type="button" class="false" value="取消" onclick="window.history.go(-1)">
                </div>
            </div>
        </form>
    </div>
</div>
</body>
<script>
    function replyImageFunc() {
        var url = window.URL.createObjectURL($("#replyImage")[0].files[0]);
        $("#replyImageShow").attr('src', url);
        $("#replyImageShow").css("display", "");
    };
</script>
</html>